package com.lxmes.base.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.base.domain.JcProductionDay;
import com.lxmes.base.service.IJcProductionDayService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 生产日时维护Controller
 * 
 * @author 张志煜
 * @date 2022-11-29
 */
@RestController
@RequestMapping("/base/productionDay")
public class JcProductionDayController extends BaseController
{
    @Autowired
    private IJcProductionDayService jcProductionDayService;

    /**
     * 查询生产日时维护列表
     */
    @PreAuthorize("@ss.hasPermi('base:productionDay:list')")
    @GetMapping("/list")
    public TableDataInfo list(JcProductionDay jcProductionDay)
    {
        startPage();
        List<JcProductionDay> list = jcProductionDayService.selectJcProductionDayList(jcProductionDay);
        return getDataTable(list);
    }

    /**
     * 导出生产日时维护列表
     */
    @PreAuthorize("@ss.hasPermi('base:productionDay:export')")
    @Log(title = "生产日时维护", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JcProductionDay jcProductionDay)
    {
        List<JcProductionDay> list = jcProductionDayService.selectJcProductionDayList(jcProductionDay);
        ExcelUtil<JcProductionDay> util = new ExcelUtil<JcProductionDay>(JcProductionDay.class);
        util.exportExcel(response, list, "生产日时维护数据");
    }

    /**
     * 获取生产日时维护详细信息
     */
    @PreAuthorize("@ss.hasPermi('base:productionDay:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(jcProductionDayService.selectJcProductionDayById(id));
    }

    /**
     * 新增生产日时维护
     */
    @PreAuthorize("@ss.hasPermi('base:productionDay:add')")
    @Log(title = "生产日时维护", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JcProductionDay jcProductionDay)
    {
        return toAjax(jcProductionDayService.insertJcProductionDay(jcProductionDay));
    }

    /**
     * 修改生产日时维护
     */
    @PreAuthorize("@ss.hasPermi('base:productionDay:edit')")
    @Log(title = "生产日时维护", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JcProductionDay jcProductionDay)
    {
        return toAjax(jcProductionDayService.updateJcProductionDay(jcProductionDay));
    }

    /**
     * 删除生产日时维护
     */
    @PreAuthorize("@ss.hasPermi('base:productionDay:remove')")
    @Log(title = "生产日时维护", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(jcProductionDayService.deleteJcProductionDayByIds(ids));
    }
}
